#ifndef C_DB_Config_H
#define C_DB_Config_H

#define							DB_OK						0
#define							DB_OPEN_FAILURE				-1
#define							DB_EXC_FAILURE				-2
#define							DB_INEXISTENCE				-3

#include <string.h>
#include <string>
#include "../Log/CLog.h"

using namespace std;

class CDBConfig
{
public:
	CDBConfig();
	~CDBConfig();

	//建立数据库，插入数据表等
	int IniDBConf(const char * DBName);

    int InitTransParam();
	//读写数据库配置
	int ReadDBConfig(const char * pKey, const char *  defaultValue,char * Result);
	int WriteDBConfig(const char *  pKey, const char *  pValue);
	//读写数据库文件
	int ReadDBFile(const char * pFileName,unsigned char * pFileValue,int *nLen);
	int WriteDBFile(const char * pFileName, unsigned char * pFileValue,int nLen);
	//数据库回调函数
	static int GetTerConf(void* para,int nCount,char** column_value,char** column_name);
	static int SearchTerConf(void* para,int nCount,char** column_value,char** column_name);

	int Sqlite_ExcuteSQL(const char * strSQL);
	string Sqlite_InquireSQL(const char * strSQL);
private:
	char * m_pDBName;
	CLog * m_pLog;									        //日志模块
};

#endif
